// ===================================================================
// FISIER: Source/client/root/uiSpecialStorage.py
// Blocuri OfflineShop: 10
// Fiecare bloc: 'CAUTA' = cateva linii de context existente inainte,
//               'ADAUGA' = codul sistemului (liniile originale din Sinners).
// ===================================================================

// ---------- [1] linii 17-19 (bloc #if) ----------
// CAUTA:
import constInfo
import shop
import ime
import exchange
// ADAUGA (dupa liniile de mai sus):
if app.__ENABLE_NEW_OFFLINESHOP__:
	import offlineshop
	import uiNewOfflineShop
// (urmat de:)
//   
//   class SpecialStorageWindow(ui.ScriptWindow):

// ---------- [2] linii 165-167 (bloc #if) ----------
// CAUTA:
			self.dlgSplitItems.Close()
		self.Hide()

	def ClickSortSpecialInventory(self):
// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop() or uiNewOfflineShop.IsBuildingAuction():
				return
// (urmat de:)
//   
//   		net.SendChatPacket(self.COMMANDS[self.categoryPageIndex])

// ---------- [3] linii 226-228 (bloc #if) ----------
// CAUTA:
			itemVnum = player.GetItemIndex(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], slotIndex)
			if itemVnum != 0:
				self.tooltipItem.SetInventoryItem(slotIndex, self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"])
				self.tooltipItem.AppendEmojiForInventory(slotIndex, itemVnum)
// ADAUGA (dupa liniile de mai sus):
				if app.__ENABLE_NEW_OFFLINESHOP__:
					if uiNewOfflineShop.IsBuildingShop() or uiNewOfflineShop.IsBuildingAuction():
						self.__AddTooltipSaleMode(slotIndex)
// (urmat de:)
//   
//   	if app.__ENABLE_NEW_OFFLINESHOP__:

// ---------- [4] linii 230-237 (bloc #if) ----------
// CAUTA:
				if app.__ENABLE_NEW_OFFLINESHOP__:
					if uiNewOfflineShop.IsBuildingShop() or uiNewOfflineShop.IsBuildingAuction():
						self.__AddTooltipSaleMode(slotIndex)

// ADAUGA (dupa liniile de mai sus):
	if app.__ENABLE_NEW_OFFLINESHOP__:
		def __AddTooltipSaleMode(self, slot):
			itemIndex = player.GetItemIndex(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], slot)
			if itemIndex !=0:
				item.SelectItem(itemIndex)
				if item.IsAntiFlag(item.ANTIFLAG_MYSHOP) or item.IsAntiFlag(item.ANTIFLAG_GIVE):
					return
				self.tooltipItem.AddRightClickForSale()
// (urmat de:)
//   
//   	def OnPressEscapeKey(self):

// ---------- [5] linii 260-263 (bloc #if) ----------
// CAUTA:
		self.ShowToolTip(overSlotPos)

	def OnPickItem(self, count):
		itemSlotIndex = self.dlgSplitItems.itemGlobalSlotIndex
// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop() and uiNewOfflineShop.IsSaleSlot(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], itemSlotIndex):
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
				return
// (urmat de:)
//   
//   		selectedItemVNum = player.GetItemIndex(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], itemSlotIndex)

// ---------- [6] linii 311-314 (bloc #if) ----------
// CAUTA:
				self.wndItem.SetUseMode(False)
				snd.PlaySound("sound/ui/pick.wav")

	def __SellItem(self, itemSlotPos):
// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop():
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
				return
// (urmat de:)
//   
//   		self.sellingSlotNumber = itemSlotPos

// ---------- [7] linii 350-353 (bloc #if) ----------
// CAUTA:

		constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)

	def SellItem(self):
// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop() and uiNewOfflineShop.IsSaleSlot(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], self.sellingSlotNumber):
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
				return
// (urmat de:)
//   		net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"])
//   		snd.PlaySound("sound/ui/money.wav")

// ---------- [8] linii 378-381 (bloc #if) ----------
// CAUTA:

			attachedSlotType = mouseModule.mouseController.GetAttachedType()
			attachedSlotPos = mouseModule.mouseController.GetRealAttachedSlotNumber()
			attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
// ADAUGA (dupa liniile de mai sus):
			if app.__ENABLE_NEW_OFFLINESHOP__:
				if uiNewOfflineShop.IsBuildingShop() and uiNewOfflineShop.IsSaleSlot(attachedInvenType,attachedSlotPos):
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
					return
// (urmat de:)
//   			if player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
//   				mouseModule.mouseController.RunCallBack("INVENTORY")

// ---------- [9] linii 442-454 (bloc #if) ----------
// CAUTA:
			return

		item.SelectItem(ItemVNum)

// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop():
				if not item.IsAntiFlag(item.ANTIFLAG_GIVE) and not item.IsAntiFlag(item.ANTIFLAG_MYSHOP):
					offlineshop.ShopBuilding_AddItem(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], slotIndex)
				else:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
				return
			elif uiNewOfflineShop.IsBuildingAuction():
				if not item.IsAntiFlag(item.ANTIFLAG_GIVE) and not item.IsAntiFlag(item.ANTIFLAG_MYSHOP):
					offlineshop.AuctionBuilding_AddItem(self.SLOT_WINDOW_TYPE[self.categoryPageIndex]["window"], slotIndex)
				else:
					chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.OFFLINESHOP_CANT_SELECT_ITEM_DURING_BUILING)
				return
// (urmat de:)
//   
//   		if item.GetItemType() == item.ITEM_TYPE_GIFTBOX and app.IsPressed(app.DIK_LCONTROL) and not exchange.isTrading():

// ---------- [10] linii 496-499 (bloc #if) ----------
// CAUTA:
		if uiPrivateShopBuilder.IsBuildingPrivateShop():
			chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
			return

// ADAUGA (dupa liniile de mai sus):
		if app.__ENABLE_NEW_OFFLINESHOP__:
			if uiNewOfflineShop.IsBuildingShop() or uiNewOfflineShop.IsBuildingAuction():
				chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
				return
// (urmat de:)
//   
//   		net.SendItemMovePacket(srcSlotWindow , srcSlotPos, dstSlotWindow, dstSlotPos, srcItemCount)

